﻿namespace WebPacker.Configuration
{
	using System;
	using System.Text;
	using NXml.Serialization.Converters;

	public class EncodingConverter : IXmlConverter
	{
		public bool Accept(Type type)
		{
			return type == typeof(Encoding);
		}

		public object Parse(Type type, string value)
		{
			return Encoding.GetEncoding(value);
		}

		public string ToString(Type type, object value)
		{
			return ((Encoding)value).WebName;
		}
	}
}
